/**
 * Created by user on 17/2/17.
 */
module.exports = class JsonResponse {
    constructor(ctx) {
        this.ctx = ctx;
    }

    success(data = []) {
        this.ctx.set('Content-Type', 'application/json');
        this.ctx.body = {
            code: 0,
            message: '成功',
            data: data
        };
    }

    error(code, message, data = []) {
        this.ctx.set('Content-Type', 'application/json');
        this.ctx.body = { code, message, data };
    }
};
